package common


fun <T> Direction.doDirectionAction(
        upAction:()->T,
        downAction:()->T,
        leftAction:()->T,
        rightAction:()->T):T{
    return when (this) {
        Direction.LEFT -> leftAction()
        Direction.RIGHT->rightAction()
        Direction.DOWN->downAction();
        Direction.UP->upAction();
    }
}


//针对List做一个扩展的函数；

inline fun <reified R> List<Any>.filterAndForEach(eachEveryData:(R)->Unit){
    this.filter {it is R }.map {it as R  }.forEach { eachEveryData(it) }
}